package com.lanxiao.cloud.user.api.fill;

import cn.hutool.core.collection.CollUtil;
import com.lanxiao.cloud.common.core.dto.BaseDto;
import com.lanxiao.cloud.common.core.dto.UserBaseDto;
import com.lanxiao.cloud.common.fill.FillHandle;
import com.lanxiao.cloud.common.fill.FillType;
import com.lanxiao.cloud.common.fill.IFillHandleService;
import com.lanxiao.cloud.user.api.UserDubboApi;
import java.util.List;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

/**
 * @author ：qiaoliang
 * @date ：2021-09-13
 */
@Service
public class FillUserInfoServiceImpl<T extends BaseDto<Long>>
    implements IFillHandleService<T, UserBaseDto<Long>, Long> {

  @DubboReference
  private UserDubboApi userDubboApi;

  @Override
  public void handle(List<T> list, FillHandle<T, UserBaseDto<Long>, Long> fillHandle) {
    final List<Long> ids = this.functionResult(list, fillHandle);
    if(CollUtil.isEmpty(ids)){
      return;
    }
    //获取用户信息
    this.appointmentResult(list, fillHandle, userDubboApi.findByIds(ids));
  }

  @Override
  public FillType type() {
    return FillType.USER_INFO;
  }

}
